<template>
  <div class="bus-apply page">
    <div class="form">
      <text-input v-model="apply.title"   label="标题"></text-input>
      <image-upload  v-model="apply.img" class="plane image-upload" title="相关照片" icon="iconhuodong1"></image-upload>
      <text-area class="plane"  v-model="apply.content" icon="iconkaohejilu" title="内容"></text-area>
      <div @click="confirm" class="btn plane" v-if="!apply.status">提交</div>
      <!--      <span class="more" @click="more()">申请记录</span>-->
    </div>
  </div>
</template>

<script>
import textInput from '../../../components/form/text-input'
import textArea from '../../../components/form/text-area'
import imageUpload from '@/components/form/image-upload'
// import labelSwitch from '../../../components/form/label-switch'
import { getAdvise, applyAdvise } from '../../../api/apply'
import { showCorrect } from '../../../dialog'

export default {
  components: {
    textArea, textInput, imageUpload
  },
  mounted () {

  },
  created () {
    this.apply.id = this.$route.query.id
    if (this.apply.id) {
      getAdvise(this.apply.id).then(res => {
        this.apply = res.data
      })
    }
  },
  methods: {
    confirm () {
      applyAdvise(this.apply).then(res => {
        this.apply = res.data
        showCorrect('提交成功,等待查阅').then(res => {
          this.$router.push({
            path: '/apply/advise/list',
            query: {
              type: this.apply.type,
              top: 0
            }
          })
        })
      })
    }
  },
  data () {
    return {
      apply: {
        status: null,
        img: null,
        title: null,
        content: null
      }
    }
  }
}
</script>

<style scoped lang="stylus">
.bus-apply
  overflow scroll
  padding-bottom 20px
  .form
    margin-top 20px
    .plane
      margin-top 15px
    .btn
      margin-top 20px
      height:44px;
      background:rgba(0,156,78,1);
      border-radius:20px;
      dpr-font(14Px)
      color white
      display flex
      align-items center
      justify-content center
  .more
    margin-top 20px
    color gray
    display flex
    align-items center
    justify-content center
    dpr-font(12Px)
</style>
